﻿@model Property4U.Models.OfType

@{
    ViewBag.Title = "Edit";
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Type</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.ImageFile, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <input type="file" accept="image/*" name="imgFile" id="imgFile" value="Choose File" class="form-control" />
                @Html.HiddenFor(model => model.ImageFile, new { id = "ImageFile" })
                <p style="font-size:small; color:#428bca;">current selected image <b>@Html.DisplayFor(model => model.ImageFile)</b></p>
                <a href="@Url.Content("~/Content/Uploads/Types/" + Model.ImageFile)"><img src="@Url.Content("~/Content/Uploads/Types/" + Model.ImageFile)" alt="Image" id="transparent-bg" @*width="160" height="30"*@ /></a>
                @Html.HiddenFor(model => model.ImageSize, new { id = "ImageSize" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        @*<div class="form-group">
            @Html.LabelFor(model => model.ImageSize, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.ImageSize, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.ImageSize, "", new { @class = "text-danger" })
            </div>
        </div>*@

        @Html.HiddenFor(model => model.LastEdit, htmlAttributes: new { @Value = ViewBag.LastEdit })

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section scripts {
    <script type="text/javascript">
            jQuery('#imgFile').change('input propertychange paste', function () {
                $("#ImageFile").val($(this).val());
            });
    </script>
}